]> dgit.raspbian.org Git - gnome-shell.git/commitdiff
js: Check for this.constructor type instead of new.target
authorMarco Trevisan (Treviño) <mail@3v1n0.net>
Thu, 18 Apr 2019 20:55:34 +0000 (15:55 -0500)
committerMarco Trevisan (Treviño) <mail@3v1n0.net>
Sat, 27 Apr 2019 01:48:52 +0000 (20:48 -0500)
Use more ES6-inspired check for classes initializations.

https://gitlab.gnome.org/GNOME/gnome-shell/merge_requests/503

js/ui/appDisplay.js
js/ui/popupMenu.js
js/ui/status/keyboard.js
js/ui/status/network.js
js/ui/workspace.js

index 1dd182b176aff86e8c375d715600b993ffd169d1..8981bbc96ce45132007802ae2d14cfe0b3a8cc2f 100644 (file)
@@ -98,8 +98,8 @@ function clamp(value, min, max) {
 
 class BaseAppView {
     constructor(params, gridParams) {
-        if (new.target === BaseAppView)
-            throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+        if (this.constructor === BaseAppView)
+            throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
 
         gridParams = Params.parse(gridParams, { xAlign: St.Align.MIDDLE,
                                                 columnLimit: MAX_COLUMNS,
index d61d18792ff4ecd183ca9b0cfe82154958eb16f2..6bbdd3eec736781246cf2e7ccfb4150cbb1fb278 100644 (file)
@@ -397,8 +397,8 @@ var PopupImageMenuItem = class extends PopupBaseMenuItem {
 
 var PopupMenuBase = class {
     constructor(sourceActor, styleClass) {
-        if (new.target === PopupMenuBase)
-            throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+        if (this.constructor === PopupMenuBase)
+            throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
 
         this.sourceActor = sourceActor;
         this._parent = null;
index d711a5453e61f7cd19905a4c61d04f832c7d7c9e..274147fe42a06fb1952f3bbc0344115a2a6c70d8 100644 (file)
@@ -125,8 +125,8 @@ class InputSourceSwitcher extends SwitcherPopup.SwitcherList {
 
 var InputSourceSettings = class {
     constructor() {
-        if (new.target === InputSourceSettings)
-            throw new TypeError('Cannot instantiate abstract class ' + new.target.name);
+        if (this.constructor === InputSourceSettings)
+            throw new TypeError(`Cannot instantiate abstract class ${this.constructor.name}`);
     }
 
     _emitInputSourcesChanged() {
index e6551f21714e41ab34da969a9f72f22517a9689f..9354183d312bb10ac4a9b8d20bc72e94baaf56c6 100644 (file)
@@ -167,10 +167,10 @@ var NMConnectionItem = class {
 };
 Signals.addSignalMethods(NMConnectionItem.prototype);
 
-var NMConnectionSection = class {
+var NMConnectionSection = class NMConnectionSection {
     constructor(client) {
-        if (new.target === NMConnectionSection)
-            throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
+        if (this.constructor === NMConnectionSection)
+            throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
 
         this._client = client;
 
@@ -297,12 +297,13 @@ var NMConnectionSection = class {
 };
 Signals.addSignalMethods(NMConnectionSection.prototype);
 
-var NMConnectionDevice = class extends NMConnectionSection {
+var NMConnectionDevice = class NMConnectionDevice extends NMConnectionSection {
     constructor(client, device) {
-        if (new.target === NMConnectionDevice)
-            throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
-
         super(client);
+
+        if (this.constructor === NMConnectionDevice)
+            throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
+
         this._device = device;
         this._description = '';
 
index 9c58861449e80aaa5bed5a075b7ccd378f9ccdac..cf52684c05ea7911fc22a88ccfbeccaaf09f311b 100644 (file)
@@ -786,8 +786,8 @@ var WindowPositionFlags = {
 
 var LayoutStrategy = class {
     constructor(monitor, rowSpacing, columnSpacing) {
-        if (new.target === LayoutStrategy)
-            throw new TypeError('Cannot instantiate abstract type ' + new.target.name);
+        if (this.constructor === LayoutStrategy)
+            throw new TypeError(`Cannot instantiate abstract type ${this.constructor.name}`);
 
         this._monitor = monitor;
         this._rowSpacing = rowSpacing;